﻿@using ThuySan.Areas.Backend.Models
@model IEnumerable<dynamic>
@{
    Layout = "~/Areas/Backend/Views/Shared/_Layout.cshtml";
    Header header = new Header {
                                       Common = "ViewUserControl_Product_Index",
                                       CurentCommon = "Category",
                                       PageHeader = "Manage Product",
                                       Menulv1 = "01",
                                       Menulv2 = "0102"
                               };
    ViewData[Header.Key] = header;
    ViewBag.Title = "Manage Product - Admin Control Panel";
}
@(Html.Telerik().Grid(Model).Name("grid").Columns(c =>
                                                      {
                                                          c.Bound(typeof (int), "ProductId").Title("#").Width(50);
                                                          c.Bound(typeof (string), "Name");
                                                          c.Bound(typeof (string), "CName").Title("Category");
                                                          c.Bound(typeof (int), "Priority");
                                                          c.Bound("Status").Filterable(false).ClientTemplate("<input <#= Status #> class=\"check-box\" disabled=\"disabled\" type=\"checkbox\" />");
                                                          c.Bound("IsReduced").Filterable(false).ClientTemplate("<input <#= IsReduced #> class=\"check-box\" disabled=\"disabled\" type=\"checkbox\" />");
                                                          c.Bound("IsVisibled").Filterable(false).ClientTemplate("<input <#= IsVisibled #> class=\"check-box\" disabled=\"disabled\" type=\"checkbox\" />");
                                                          c.Bound(typeof (int), "Viewer");
                                                          c.Template(v => v.ProductId).ClientTemplate(Html.ActionLink("<span class=\"t-icon t-edit\"></span>", "Edit", new {
                                                                                                                                                                                   id = "<#=ProductId#>"
                                                                                                                                                                           }, new {
                                                                                                                                                                                          @class = "t-button t-button-icon t-grid-edit",
                                                                                                                                                                                  }).ToHtmlString() + "<a class=\"t-button t-button-icon t-grid-delete\" href=\"javascript:Delete(<#=ProductId#>);\"><span class=\"t-icon t-delete\"></span></a>").Width(80);
                                                      }).Sortable(c => c.Enabled(true)).Filterable().DataKeys(c => c.Add("ProductId")).Pageable(c =>
                                                                                                                                                    {
                                                                                                                                                        c.Enabled(true);
                                                                                                                                                        c.PageSize(25);
                                                                                                                                                    }).DataBinding(c => c.Ajax().Select("GetList", "Product")))
@section script
{
    <script type="text/javascript">
        function Delete(id) {
            if (confirm("Do you want to delete?"))
                $.post('@Url.Action("Delete", "Product")', { id: id }, function() {
                    $("#grid").data("tGrid").ajaxRequest();
                });
        }
    </script>
}